package com.cares.event.listener.servicerun;

/**
 * 每个一秒钟定时查找类变量里的任务
 */
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

public class EventTaskListener implements ServletContextListener {

	private java.util.Timer timer = null ;  
	
	@Override
	public void contextDestroyed(ServletContextEvent arg0) {

	}

	@Override
	public void contextInitialized(ServletContextEvent event) {
		timer = new java.util.Timer(true) ;  
	    event.getServletContext().log("每秒定时查找任务开始!") ;
	    //服务启动延时60秒执行，每秒定时读取任务
	    timer.schedule(new EventTask(event.getServletContext()), 60000, 1000) ;  
	    event.getServletContext().log("已经添加任务调度表" ) ;  
	}

}
